﻿using System;
using System.Web;

namespace Hk.Biker.Infrastructure
{
    public class AppSettings
    {
        public static string CurrentDomain
        {
            get
            {
                HttpRequest request = HttpContext.Current.Request;
                string currentDomain = string.Format("{0}{1}{2}{3}", request.Url.Scheme, Uri.SchemeDelimiter,
                    request.Url.Host, request.Url.IsDefaultPort ? string.Empty : string.Format(":{0}", request.Url.Port));
                return currentDomain;
            }
        }

        #region scripts

        public static string GoogleAnalytics
        {
            get
            {
                return @"<script>
	                      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	                      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	                      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	                      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
	                      ga('create', 'UA-35905523-2', 'auto');
	                      ga('send', 'pageview');
	                    </script>";
            }
        }

        public static string FacebookSDK
        {
            get
            {
                return @"<script>
                            (function (d, s, id) {
                                var js, fjs = d.getElementsByTagName(s)[0];
                                if (d.getElementById(id)) return;
                                js = d.createElement(s); js.id = id;
                                js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=526459514070926&version=v2.0';
                                fjs.parentNode.insertBefore(js, fjs);
                            }(document, 'script', 'facebook-jssdk'));
                        </script>";
            }
        }

        public static string GooglePlus
        {
            get
            {
                return @"<script>
                            (function () {
                                var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                                po.src = 'https://apis.google.com/js/platform.js';
                                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
                            })();
                        </script>";
            }
        }

        public static string AddThis
        {
            get
            {
                return @"<script type='text/javascript' src='//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f3a2e9f02cec0f9'></script>";
            }
        }

        #endregion
    }
}